package com.spring;

import com.bean.Book;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestConfiguration {

    @Autowired
    private Book book1;
    public static void main(String[] args) {
        ApplicationContext context=new AnnotationConfigApplicationContext(ConfigurationTest.class);
        Book book2 = context.getBean("book2", Book.class);
        System.out.println("book2 "+book2);

        TestConfiguration testConfiguration=new TestConfiguration();
        Book book1 = testConfiguration.book1;
        System.out.println(book1);
        testConfiguration.test1();
    }

    @Test
    public void test1(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean.xml");
        Book b = context.getBean("b", Book.class);
        System.out.println("b "+b);
        TestConfiguration testConfiguration=new TestConfiguration();
        Book book2 = testConfiguration.book1;
        System.out.println(book2);

    }
}
